#ifndef _LED_H_
#define _LED_H_

#include "Global.h"

//---- H
#define H1_PORT         P2
#define H1_GPIO_PIN     DEF_GPIO(6)    
#define H1_PIN          DEF_PIN(P2,6)   
#define H1_UP           DEF_UP(P2)
#define H1_TRIS         DEF_TRIS(P2) 

#define H2_PORT         P3
#define H2_GPIO_PIN     DEF_GPIO(0)    
#define H2_PIN          DEF_PIN(P3,0)   
#define H2_UP           DEF_UP(P3)
#define H2_TRIS         DEF_TRIS(P3) 

#define H3_PORT         P3
#define H3_GPIO_PIN     DEF_GPIO(1)    
#define H3_PIN          DEF_PIN(P3,1)   
#define H3_UP           DEF_UP(P3)
#define H3_TRIS         DEF_TRIS(P3) 

//---- L
#define V1_PORT         P3
#define V1_GPIO_PIN     DEF_GPIO(2)    
#define V1_PIN          DEF_PIN(P3,2)   
#define V1_UP           DEF_UP(P3)
#define V1_TRIS         DEF_TRIS(P3) 

#define V2_PORT         P3
#define V2_GPIO_PIN     DEF_GPIO(6)    
#define V2_PIN          DEF_PIN(P3,6)   
#define V2_UP           DEF_UP(P3)
#define V2_TRIS         DEF_TRIS(P3) 

#define V3_PORT         P0
#define V3_GPIO_PIN     DEF_GPIO(5)    
#define V3_PIN          DEF_PIN(P0,5)   
#define V3_UP           DEF_UP(P0)
#define V3_TRIS         DEF_TRIS(P0) 

// #define BOOST_PORT         P3
// #define BOOST_GPIO_PIN     DEF_GPIO(6)    
// #define BOOST_PIN          DEF_PIN(P3,6)   
// #define BOOST_UP           DEF_UP(P3)
// #define BOOST_TRIS         DEF_TRIS(P3) 

#define SET_OUT(PORT_PIN,hl)    do{PORT_PIN##_PIN = hl; GPIO_ENABLE_OUTPUT(PORT_PIN##_TRIS,PORT_PIN##_GPIO_PIN);GPIO_DISABLE_UP(PORT_PIN##_UP,PORT_PIN##_GPIO_PIN); }while(0)
#define OPEN_LED(PORT)      PORT##_PIN = LOW
#define CLOSE_LED(PORT)     PORT##_PIN = HIGH
#define FLASH_LED(PORT)     PORT##_PIN = ~PORT##_PIN


typedef struct 
{
    uint8 LED1:1;
    uint8 LED2:1;
    uint8 LED3:1;
    uint8 Reversed0_0:1;
    uint8 LED1_F:1;     // LED1 闪烁
    uint8 LED2_F:1;     // LED2 闪烁
    uint8 LED3_F:1;     // LED3 闪烁
    uint8 Reversed0_1:1;

    uint8 LED4:1;
    uint8 LED5:1;
    uint8 LED6:1;
    uint8 Reserved1_0:1;
    uint8 LED4_F:1;     // LED4 闪烁
    uint8 LED5_F:1;     // LED5 闪烁
    uint8 LED6_F:1;     // LED6 闪烁
    uint8 Reserved1_1:1;
    
    uint8 LED10:1;
    uint8 LED11:1;
    uint8 LED12:1;
    uint8 Reserved2_0:1;
    uint8 LED10_F:1;     // LED10 闪烁
    uint8 LED11_F:1;     // LED11 闪烁
    uint8 LED12_F:1;     // LED12 闪烁
    uint8 Reserved2_1:1;
}Typedef_LED;

typedef union
{
    Typedef_LED Detail;
    uint8 Buf[sizeof(Typedef_LED)];
}U_LED;

extern XDATA	U_LED    DispBuf;


// typedef enum
// {
//     COLOR_OFF = 0,
//     COLOR_RED,
//     COLOR_BLUE,
//     COLOR_RB,
// };

// enum
// {
//     LED_UNCHANGE = 0x00,
//     LED_ON       = 0x01,
//     LED_OFF      = 0x02,
//     LED_FLASH    = 0x03,
// };

#define C_KEY_LED_TIME  25

enum
{
    LED_KEY_OFF = 0,
    LED_KEY1,               //---- ��Ӧ S11 - LED4
    LED_KEY2,               //---- ��Ӧ S12 - LED8
    LED_KEY3,               //---- ��Ӧ S13 - LED9
    LED_KEY4,               //---- ��Ӧ S14 - LED13
    LED_KEY5,               //---- ��Ӧ S15 - LED14 
    LED_KEY6,               //---- ��Ӧ S21 - LED12   
};
// enum
// {
//     LED_KEY_ALL_OFF = 0,            
//     LED_KEY_ChongShui,          
//     LED_KEY_TunXi,               
//     LED_KEY_FuXi,              
//     LED_KEY_HongGan,               
//     LED_KEY_LengReQingXi,        
//     LED_KEY_TingZhi,               
// };
enum
{
    LED_KEY_ALL_OFF = 0,            
    LED_KEY_ChongShui,     
    LED_KEY_TingZhi,                
    LED_KEY_TunXi,               
    LED_KEY_FuXi,              
    LED_KEY_HongGan,               
    LED_KEY_LengReQingXi,            
};

// #define     LED_THK_TingZhi         0x20    //0x01
// #define     LED_THK_TunXi           0x02
// #define     LED_THK_FuXi            0x04
// #define     LED_THK_HongGan         0x08
// #define     LED_THK_LengReQingXi    0x10
// #define     LED_THK_ChongShui       0x01    //0x20

//extern Typedef_LED LedColor;

void    initLED(void);
// void    LED_Set(uint8 led1, uint8 led2, uint8 led3);
void    LED_Main(void);
void    LED_DispTouchKey(u8 key);
void    LED_DisplayLevel(u8 level);
// void    LED_DisplayKey(void);
void LED_DisplayKey(uint8 key);
void    LED_ClrDispTouchKey(void);
void    LED_AllOff(void);
void    LED_AllOn(void);
void    LED_PowerSaveSetting(void);
void    LED_DisplayPaoMoDun(u8 level);
#endif